<?php require_once('Connections/conn.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
{
  if (PHP_VERSION < 6) {
    $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
  }

  $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

  switch ($theType) {
    case "text":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;    
    case "long":
    case "int":
      $theValue = ($theValue != "") ? intval($theValue) : "NULL";
      break;
    case "double":
      $theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
      break;
    case "date":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;
    case "defined":
      $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
      break;
  }
  return $theValue;
}
}

$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
  $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
}
 

$maxRows_rs_category = 1000;
$pageNum_rs_category = 0;
if (isset($_GET['pageNum_rs_category'])) {
  $pageNum_rs_category = $_GET['pageNum_rs_category'];
}
$startRow_rs_category = $pageNum_rs_category * $maxRows_rs_category;

mysql_select_db($database_conn, $conn);
$query_rs_category = "SELECT * FROM category";
$query_limit_rs_category = sprintf("%s LIMIT %d, %d", $query_rs_category, $startRow_rs_category, $maxRows_rs_category);
$rs_category = mysql_query($query_limit_rs_category, $conn) or die(mysql_error());
$row_rs_category = mysql_fetch_assoc($rs_category);

if (isset($_GET['totalRows_rs_category'])) {
  $totalRows_rs_category = $_GET['totalRows_rs_category'];
} else {
  $all_rs_category = mysql_query($query_rs_category);
  $totalRows_rs_category = mysql_num_rows($all_rs_category);
}
$totalPages_rs_category = ceil($totalRows_rs_category/$maxRows_rs_category)-1;
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>

<body>
<table border="0" cellpadding="4" cellspacing="0">
  <?php do { ?>
    <tr>
      <td><?php 
	  
	   $insertSQL = sprintf("INSERT INTO content ( keywords, ptitle, pcontent, categoryid,ispublished) VALUES ( %s, %s, %s, %s,  %s)",
                       GetSQLValueString($row_rs_category['categoryname'], "text"),
                       GetSQLValueString($row_rs_category['categoryname'], "text"),
                       GetSQLValueString($row_rs_category['categoryname'], "text"),
                       GetSQLValueString($row_rs_category['categoryid'], "int"),
					    GetSQLValueString($row_rs_category['ispublished'], "int"));

  mysql_select_db($database_conn, $conn);
  $Result1 = mysql_query($insertSQL, $conn) or die(mysql_error());
  echo "Successfull<br />";
	  ?></td>
    </tr>
    <?php } while ($row_rs_category = mysql_fetch_assoc($rs_category)); ?>
</table>

</body>
</html>